<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java并发队列深度对比：ConcurrentLinkedQueue vs LinkedBlockingQueue</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            position: relative;
        }
        .code-header {
            background-color: #1e1e1e;
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
            padding: 8px 15px;
            color: #ccc;
            font-family: monospace;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .copy-btn {
            color: #ccc;
            background: none;
            border: none;
            cursor: pointer;
            font-size: 0.8rem;
        }
        .copy-btn:hover {
            color: #fff;
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
            overflow: hidden;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
        .comparison-table th, .comparison-table td {
            padding: 15px;
            text-align: left;
            border-bottom: 1px solid #e2e8f0;
        }
        .comparison-table th {
            background-color: #f8fafc;
            font-weight: 600;
            color: #4a5568;
        }
        .comparison-table tr:last-child td {
            border-bottom: none;
        }
        .feature-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 16px;
            flex-shrink: 0;
        }
        .feature-item {
            display: flex;
            align-items: flex-start;
        }
        .feature-content {
            flex: 1;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col items-center text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6 serif">Java并发队列深度解析</h1>
                <h2 class="text-2xl md:text-3xl font-medium mb-8">ConcurrentLinkedQueue vs LinkedBlockingQueue</h2>
                <p class="text-xl max-w-3xl opacity-90">探索两种高效线程安全队列的设计哲学、实现差异及适用场景</p>
                <div class="mt-10 flex space-x-4">
                    <div class="px-4 py-2 bg-white text-purple-600 font-semibold rounded-full shadow-lg">高并发处理</div>
                    <div class="px-4 py-2 bg-white text-purple-600 font-semibold rounded-full shadow-lg">线程安全</div>
                    <div class="px-4 py-2 bg-white text-purple-600 font-semibold rounded-full shadow-lg">性能优化</div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-5xl mx-auto px-4 py-16">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="prose prose-lg max-w-none">
                <p class="text-gray-700 text-lg leading-relaxed">
                    <span class="text-4xl float-left mr-3 font-bold text-purple-600">C</span>oncurrentLinkedQueue 和 LinkedBlockingQueue 是 Java 并发包中两种高效的线程安全队列实现，它们都能在多线程环境下安全地进行队列操作，但在设计目标、内部实现和使用场景上却有着显著的区别。本文将从数据结构、并发控制、性能特点等方面进行深入对比，帮助开发者根据实际需求选择合适的队列实现。
                </p>
            </div>
        </section>

        <!-- Comparison Sections -->
        <section class="grid md:grid-cols-2 gap-8 mb-16">
            <!-- ConcurrentLinkedQueue Card -->
            <div class="bg-white rounded-xl p-8 card-hover">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-blue-100 text-blue-600">
                        <i class="fas fa-bolt text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold serif">ConcurrentLinkedQueue</h3>
                </div>
                <div class="space-y-4">
                    <div class="feature-item">
                        <div class="feature-icon bg-blue-50 text-blue-500">
                            <i class="fas fa-project-diagram"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">无界单向链表</h4>
                            <p class="text-gray-600">基于非阻塞算法，使用CAS操作保证线程安全</p>
                        </div>
                    </div>
                    <div class="feature-item">
                        <div class="feature-icon bg-blue-50 text-blue-500">
                            <i class="fas fa-unlock"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">无锁设计</h4>
                            <p class="text-gray-600">避免了线程阻塞，性能非常高效</p>
                        </div>
                    </div>
                    <div class="feature-item">
                        <div class="feature-icon bg-blue-50 text-blue-500">
                            <i class="fas fa-tachometer-alt"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">高吞吐量</h4>
                            <p class="text-gray-600">适合高并发操作、无阻塞需求的场景</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- LinkedBlockingQueue Card -->
            <div class="bg-white rounded-xl p-8 card-hover">
                <div class="flex items-center mb-6">
                    <div class="feature-icon bg-purple-100 text-purple-600">
                        <i class="fas fa-lock text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold serif">LinkedBlockingQueue</h3>
                </div>
                <div class="space-y-4">
                    <div class="feature-item">
                        <div class="feature-icon bg-purple-50 text-purple-500">
                            <i class="fas fa-link"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">有界/无界双向链表</h4>
                            <p class="text-gray-600">通过两个锁和条件变量实现线程安全</p>
                        </div>
                    </div>
                    <div class="feature-item">
                        <div class="feature-icon bg-purple-50 text-purple-500">
                            <i class="fas fa-hourglass-half"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">阻塞特性</h4>
                            <p class="text-gray-600">线程在队列满或空时会等待</p>
                        </div>
                    </div>
                    <div class="feature-item">
                        <div class="feature-icon bg-purple-50 text-purple-500">
                            <i class="fas fa-exchange-alt"></i>
                        </div>
                        <div class="feature-content">
                            <h4 class="font-semibold text-lg">生产者-消费者模型</h4>
                            <p class="text-gray-600">适合线程间同步通信</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Detailed Comparison -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 serif text-center">深入对比分析</h2>
            
            <!-- Section 1 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 flex items-center">
                    <span class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center mr-3">1</span>
                    数据结构与实现方式
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-blue-600">ConcurrentLinkedQueue</h4>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span><strong>无界单向链表</strong>，使用非阻塞算法</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>通过<strong>CAS操作</strong>保证线程安全</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>入队和出队操作均使用CAS更新节点引用</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>无锁设计，性能高效</span>
                            </li>
                        </ul>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-purple-600">LinkedBlockingQueue</h4>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span><strong>有界/无界双向链表</strong></span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>通过<strong>两个锁</strong>和<strong>条件变量</strong>实现线程安全</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>独立的入队锁(put)和出队锁(take)</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>条件变量(notEmpty/notFull)用于线程同步</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- Section 2 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 flex items-center">
                    <span class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center mr-3">2</span>
                    并发控制机制
                </h3>
                <div class="bg-white p-6 rounded-lg shadow-sm mb-6">
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-xl font-semibold mb-4 text-blue-600">ConcurrentLinkedQueue</h4>
                            <p class="text-gray-700 mb-4">
                                基于CAS(Compare-And-Swap)算法保证线程安全，无需加锁，在高并发环境下表现非常出色。CAS操作依赖于硬件提供的原子性指令，在竞争激烈时可能会导致大量重试，带来一定的性能损耗。
                            </p>
                            <div class="bg-blue-50 p-4 rounded-lg">
                                <p class="font-medium text-blue-700">优势：</p>
                                <ul class="list-disc pl-5 text-blue-700">
                                    <li>无锁设计减少线程阻塞</li>
                                    <li>高并发下吞吐量高</li>
                                    <li>操作延迟低</li>
                                </ul>
                            </div>
                        </div>
                        <div>
                            <h4 class="text-xl font-semibold mb-4 text-purple-600">LinkedBlockingQueue</h4>
                            <p class="text-gray-700 mb-4">
                                通过显式加锁和条件变量来实现线程安全。入队和出队使用独立的锁，减少了锁的竞争。如果队列为空，消费者线程会在notEmpty条件上等待；如果队列已满，生产者线程会在notFull条件上等待。
                            </p>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <p class="font-medium text-purple-700">优势：</p>
                                <ul class="list-disc pl-5 text-purple-700">
                                    <li>锁分离减少竞争</li>
                                    <li>阻塞特性简化线程协作</li>
                                    <li>明确的容量控制</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Section 3 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 flex items-center">
                    <span class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center mr-3">3</span>
                    阻塞与非阻塞特性
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-blue-600">ConcurrentLinkedQueue</h4>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium mr-3">非阻塞</div>
                                <p class="text-gray-700">不支持阻塞操作，没有容量限制，操作立即返回</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium mr-3">无界</div>
                                <p class="text-gray-700">队列长度取决于实际使用情况，可能导致内存不足</p>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-purple-600">LinkedBlockingQueue</h4>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <div class="bg-purple-100 text-purple-800 px-3 py-1 rounded-full text-sm font-medium mr-3">阻塞</div>
                                <p class="text-gray-700">提供阻塞操作(put和take)，线程在队列满或空时会等待</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-purple-100 text-purple-800 px-3 py-1 rounded-full text-sm font-medium mr-3">有界</div>
                                <p class="text-gray-700">默认容量Integer.MAX_VALUE，可设置容量限制</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Section 4 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 flex items-center">
                    <span class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center mr-3">4</span>
                    性能对比
                </h3>
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <div class="grid md:grid-cols-2 gap-8">
                        <div>
                            <h4 class="text-xl font-semibold mb-4 text-blue-600">ConcurrentLinkedQueue</h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-rocket text-blue-500 mt-1 mr-2"></i>
                                    <span><strong>性能高</strong>：无锁设计，高并发下吞吐量优越</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-stopwatch text-blue-500 mt-1 mr-2"></i>
                                    <span><strong>延迟低</strong>：操作几乎没有等待时间</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-brain text-blue-500 mt-1 mr-2"></i>
                                    <span><strong>CPU利用率高</strong>：无阻塞，避免线程上下文切换</span>
                                </li>
                            </ul>
                        </div>
                        <div>
                            <h4 class="text-xl font-semibold mb-4 text-purple-600">LinkedBlockingQueue</h4>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-tachometer-alt text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>性能稍低</strong>：锁和条件变量引入额外开销</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-user-friends text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>线程协作</strong>：阻塞特性简化生产者-消费者模型</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-shield-alt text-purple-500 mt-1 mr-2"></i>
                                    <span><strong>资源保护</strong>：容量限制防止资源耗尽</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Section 5 -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 flex items-center">
                    <span class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center mr-3">5</span>
                    使用场景对比
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-blue-600">ConcurrentLinkedQueue适用场景</h4>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景1</div>
                                <p class="text-gray-700"><strong>高吞吐量需求</strong>：如日志记录、事件流处理等</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景2</div>
                                <p class="text-gray-700"><strong>无阻塞场景</strong>：不希望线程因队列满或空而阻塞</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景3</div>
                                <p class="text-gray-700"><strong>无容量限制</strong>：需要动态扩展队列容量的场景</p>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h4 class="text-xl font-semibold mb-4 text-purple-600">LinkedBlockingQueue适用场景</h4>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <div class="bg-purple-100 text-purple-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景1</div>
                                <p class="text-gray-700"><strong>生产者-消费者模型</strong>：线程间传递任务并阻塞等待</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-purple-100 text-purple-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景2</div>
                                <p class="text-gray-700"><strong>容量限制</strong>：需要显式限制队列容量</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-purple-100 text-purple-800 px-3 py-1 rounded-full text-sm font-medium mr-3">场景3</div>
                                <p class="text-gray-700"><strong>线程调度优化</strong>：利用阻塞特性避免CPU空转</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Table -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 serif text-center">特性对比总结</h2>
            <div class="bg-white rounded-lg overflow-hidden shadow-sm">
                <table class="comparison-table">
                    <thead>
                        <tr>
                            <th class="w-1/4">特性</th>
                            <th class="w-2/4">ConcurrentLinkedQueue</th>
                            <th class="w-2/4">LinkedBlockingQueue</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="font-medium">线程安全性</td>
                            <td>基于CAS算法，无锁实现</td>
                            <td>基于显式锁和条件变量实现</td>
                        </tr>
                        <tr>
                            <td class="font-medium">阻塞特性</td>
                            <td>非阻塞</td>
                            <td>阻塞，支持线程等待</td>
                        </tr>
                        <tr>
                            <td class="font-medium">容量控制</td>
                            <td>无容量限制</td>
                            <td>支持容量限制，防止内存耗尽</td>
                        </tr>
                        <tr>
                            <td class="font-medium">性能</td>
                            <td>高性能，适合高并发场景</td>
                            <td>性能较低，适合线程间的同步通信</td>
                        </tr>
                        <tr>
                            <td class="font-medium">适用场景</td>
                            <td>高并发操作、无阻塞需求</td>
                            <td>生产者-消费者模型、容量受限场景</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <!-- Code Examples -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 serif text-center">代码示例</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <!-- ConcurrentLinkedQueue Code -->
                <div class="code-block">
                    <div class="code-header">
                        <span>ConcurrentLinkedQueueDemo.java</span>
                        <button class="copy-btn"><i class="far fa-copy mr-1"></i>复制</button>
                    </div>
                    <pre class="p-4 text-gray-200 overflow-auto"><code>import java.util.concurrent.ConcurrentLinkedQueue;

public class ConcurrentLinkedQueueDemo {
    public static void main(String[] args) {
        ConcurrentLinkedQueue&lt;Integer&gt; queue = new ConcurrentLinkedQueue&lt;&gt;();
        queue.offer(1);
        queue.offer(2);

        System.out.println(queue.poll()); // 输出 1
        System.out.println(queue.poll()); // 输出 2
    }
}</code></pre>
                </div>
                
                <!-- LinkedBlockingQueue Code -->
                <div class="code-block">
                    <div class="code-header">
                        <span>LinkedBlockingQueueDemo.java</span>
                        <button class="copy-btn"><i class="far fa-copy mr-1"></i>复制</button>
                    </div>
                    <pre class="p-4 text-gray-200 overflow-auto"><code>import java.util.concurrent.LinkedBlockingQueue;

public class LinkedBlockingQueueDemo {
    public static void main(String[] args) throws InterruptedException {
        LinkedBlockingQueue&lt;Integer&gt; queue = new LinkedBlockingQueue&lt;&gt;(2);
        queue.put(1);
        queue.put(2);

        System.out.println(queue.take()); // 输出 1
        System.out.println(queue.take()); // 输出 2
    }
}</code></pre>
                </div>
            </div>
        </section>

        <!-- Conclusion -->
        <section class="bg-white p-8 rounded-xl shadow-sm mb-16">
            <h2 class="text-3xl font-bold mb-6 serif text-center">总结与选择建议</h2>
            <div class="prose prose-lg max-w-none">
                <p>在选择 <code class="bg-blue-100 text-blue-700 px-2 py-1 rounded">ConcurrentLinkedQueue</code> 和 <code class="bg-purple-100 text-purple-700 px-2 py-1 rounded">LinkedBlockingQueue</code> 时，开发者应根据具体应用场景和需求做出决策：</p>
                
                <div class="my-6 p-4 border-l-4 border-blue-500 bg-blue-50">
                    <h3 class="text-xl font-semibold text-blue-700 mb-2">选用 ConcurrentLinkedQueue 当：</h3>
                    <ul class="list-disc pl-5 text-blue-700">
                        <li>需要极高的并发性能</li>
                        <li>不希望线程因为队列状态而阻塞</li>
                        <li>队列容量不确定或可能很大</li>
                        <li>可以接受在竞争激烈时的CAS重试开销</li>
                    </ul>
                </div>
                
                <div class="my-6 p-4 border-l-4 border-purple-500 bg-purple-50">
                    <h3 class="text-xl font-semibold text-purple-700 mb-2">选用 LinkedBlockingQueue 当：</h3>
                    <ul class="list-disc pl-5 text-purple-700">
                        <li>需要实现生产者-消费者模式</li>
                        <li>需要限制队列容量防止资源耗尽</li>
                        <li>需要线程在队列空/满时阻塞等待</li>
                        <li>可以接受一定的锁竞争开销</li>
                    </ul>
                </div>
                
                <p>两种队列都是线程安全的优秀实现，但在不同的场景下表现出不同的优势。理解它们的内部实现和特性差异，将帮助开发者做出更明智的技术选型。</p>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-10">
        <div class="max-w-5xl mx-auto px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400">深入技术细节，探索最佳实践</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition-colors">
                        <i class="fas fa-external-link-alt mr-2"></i>访问技术小馆
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <!-- Mermaid Diagram (hidden by default) -->
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true
            }
        });
    </script>
    <script>
        // Copy button functionality
        document.querySelectorAll('.copy-btn').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.parentElement.nextElementSibling;
                const code = codeBlock.textContent;
                
                navigator.clipboard.writeText(code).then(() => {
                    const originalText = button.innerHTML;
                    button.innerHTML = '<i class="fas fa-check mr-1"></i>已复制';
                    setTimeout(() => {
                        button.innerHTML = originalText;
                    }, 2000);
                });
            });
        });
    </script>
</body>
</html>